package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ErpOutboundOrder;
import com.ruoyi.service.IErpOutboundOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库单管理Controller
 * 
 * @author zhp
 * @date 2025-08-19
 */
@RestController
@RequestMapping("/storage/outWarehouse")
public class ErpOutboundOrderController extends BaseController
{
    @Autowired
    private IErpOutboundOrderService erpOutboundOrderService;

    /**
     * 查询出库单管理列表
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpOutboundOrder erpOutboundOrder)
    {
        startPage();
        List<ErpOutboundOrder> list = erpOutboundOrderService.selectErpOutboundOrderList(erpOutboundOrder);
        return getDataTable(list);
    }

    /**
     * 导出出库单管理列表
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:export')")
    @Log(title = "出库单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpOutboundOrder erpOutboundOrder)
    {
        List<ErpOutboundOrder> list = erpOutboundOrderService.selectErpOutboundOrderList(erpOutboundOrder);
        ExcelUtil<ErpOutboundOrder> util = new ExcelUtil<ErpOutboundOrder>(ErpOutboundOrder.class);
        util.exportExcel(response, list, "出库单管理数据");
    }

    /**
     * 获取出库单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(erpOutboundOrderService.selectErpOutboundOrderById(id));
    }

    /**
     * 新增出库单管理
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:add')")
    @Log(title = "出库单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpOutboundOrder erpOutboundOrder)
    {
        return toAjax(erpOutboundOrderService.insertErpOutboundOrder(erpOutboundOrder));
    }

    /**
     * 修改出库单管理
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:edit')")
    @Log(title = "出库单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpOutboundOrder erpOutboundOrder)
    {
        return toAjax(erpOutboundOrderService.updateErpOutboundOrder(erpOutboundOrder));
    }

    /**
     * 删除出库单管理
     */
    @PreAuthorize("@ss.hasPermi('storage:outWarehouse:remove')")
    @Log(title = "出库单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpOutboundOrderService.deleteErpOutboundOrderByIds(ids));
    }
}
